// 执行测试任务
let request = require("@baige/request");
const { exit } = require("process");
// 接受一个数组参数
module.exports = async (port,data)=>{
    let error = [];
    for(let e of data){
        let {url,method,par,end} = e
        /**
         * {
         *  url:"",
         *  method
         *  par:any,
         *  end:any
         * }
         */
        let ends = JSON.stringify(await request[e.method](`http://127.0.0.1:${port}${url}`,par))
            end = JSON.stringify(end);
        if(ends  == end){
            console.log(`url:${url}  method:${method}  正常`)
        }else{
            console.log(`url:${url}  method:${method}  出现异常异常`,ends);
            error.push(`url:${url}  method:${method}  出现异常异常 \n${ends}===${end}`,)
        }
    }

    console.log();
    error.length && console.log(error)
    console.log("测试完成,出现异常接口共：",error.length);
    exit(0)
}